<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:r2ml="http://www.rewerse.net/I1/2006/R2ML" xmlns:r2mlv="http://www.rewerse.net/I1/2006/R2ML/R2MLV" xmlns:dc="http://purl.org/dc/elements/1.1/" targetNamespace="http://www.rewerse.net/I1/2006/R2ML" elementFormDefault="qualified" attributeFormDefault="qualified" version="0.4" xml:lang="en">
 <!--

   R2ML - The REWERSE I1 Rule Markup Language.
   Version: 0.4 Publication date: August 23, 2006
   
   URL: http://www.rewerse.net/I1
   
   The R2ML email address is:  I1.r2ml@googlemail.com

 Tested with W3C validator (XSV version: XSV 2.10-1 of 2005/04/22 13:10:49)  http://www.w3.org/2001/03/webdata/xsv 

<rdf:RDF  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"   xmlns:dc="http://purl.org/dc/elements/1.1/">
   <rdf:Description rdf:about="R2ML XML schema">
      <dc:subject>The REWERSE I1 Rule Markup Language</dc:subject>
      <dc:creator>Adrian Giurca</dc:creator>
      <dc:creator>Gerd Wagner</dc:creator>
      <dc:contributor>Sergey Lukichev</dc:contributor>
      <dc:contributor>Dragan Gasevic</dc:contributor>
      <dc:contributor>Milan Milanovic</dc:contributor>
      <dc:title>R2ML W3C XML Schema </dc:title>
      <dc:description>REWERSE I1 Rules Markup Language</dc:description> 
      <dc:type>text/xml</dc:type>
      <dc:source>R2ML.xsd</dc:source>
      <dc:date>2006-08-15</dc:date>
      <dc:rights>http://www.gnu.org/copyleft/lesser.html</dc:rights>
   </rdf:Description> 
</rdf:RDF>


R2ML.xsd - R2ML Rule markup Language W3C XML Schema 

Copyright (C)  2006  Adrian Giurca, Gerd Wagner.

This is a free software; you can redistribute it and/or  modify it under the terms of the GNU Lesser General Public License as 
published by the Free Software Foundation; either  version 2.1 of the License, or (at your option) any later version.

 This schema is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.

 You should have a copy of the GNU Lesser General Public License along with R2ML schema; if not go to http://www.gnu.org/copyleft/lesser.html  
 or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA

Standard root element
<r2ml:RuleBase xmlns:rew="http://www.rewerse.net/I1/2006/R2ML" xmlns:dc="http://purl.org/dc/elements/1.1/" 
						  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
						  xsi:schemaLocation="http://www.rewerse.net/I1/2006/R2ML  http://www.rewerse.net/I1/R2ML/0.4/r2ml.xsd">

-->
 <xs:import namespace="http://www.rewerse.net/I1/2006/R2ML/R2MLV" schemaLocation="Vocabulary/R2MLV.xsd"/>
 <xs:include schemaLocation="modules/annotations.xsd"/>
 <xs:include schemaLocation="modules/attributes.xsd"/>
 <xs:include schemaLocation="modules/terms.xsd"/>
 <xs:include schemaLocation="modules/roles.xsd"/>
 <xs:include schemaLocation="modules/formulas.xsd"/>
 <xs:include schemaLocation="modules/actions.xsd"/>
 <xs:include schemaLocation="modules/events.xsd"/>
 <!--

Elements for rule sets 

-->
 <xs:element name="RuleBase" type="r2ml:RuleBase" abstract="false"/>
 <xs:element name="RuleSet" type="r2ml:RuleSet" abstract="true"/>
 <xs:element name="DerivationRuleSet" type="r2ml:DerivationRuleSet" abstract="false" substitutionGroup="r2ml:RuleSet"/>
 <xs:element name="IntegrityRuleSet" type="r2ml:IntegrityRuleSet" abstract="false" substitutionGroup="r2ml:RuleSet"/>
 <xs:element name="ProductionRuleSet" type="r2ml:ProductionRuleSet" abstract="false" substitutionGroup="r2ml:RuleSet"/>
 <xs:element name="ReactionRuleSet" type="r2ml:ReactionRuleSet" abstract="false" substitutionGroup="r2ml:RuleSet"/>
 <!-- 

Elements for rules 

-->
 <xs:element name="Rule" type="r2ml:Rule" abstract="true"/>
 <xs:element name="IntegrityRule" type="r2ml:IntegrityRule" abstract="true" substitutionGroup="r2ml:Rule"/>
 <xs:element name="AlethicIntegrityRule" type="r2ml:AlethicIntegrityRule" abstract="false" substitutionGroup="r2ml:IntegrityRule"/>
 <xs:element name="DeonticIntegrityRule" type="r2ml:DeonticIntegrityRule" abstract="false" substitutionGroup="r2ml:IntegrityRule"/>
 <xs:element name="DerivationRule" type="r2ml:DerivationRule" abstract="false" substitutionGroup="r2ml:Rule"/>
 <xs:element name="ProductionRule" type="r2ml:ProductionRule" abstract="false" substitutionGroup="r2ml:Rule"/>
 <xs:element name="ReactionRule" type="r2ml:ReactionRule" abstract="false" substitutionGroup="r2ml:Rule"/>
 <!--
Rule Base. Capture a collection of rules. The collection contains derivation rules in a form of a DerivationRuleSet, 
production rules in a form of a ProductionRuleSet or reaction rules in a form of ReactionRulesSet.
Any rule base may have an ID for unique identification.
 -->
 <xs:complexType name="RuleBase" abstract="false">
  <xs:sequence>
   <xs:element ref="r2mlv:Vocabulary" minOccurs="0"/>
   <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="r2ml:GenericVariable" minOccurs="0" maxOccurs="unbounded"/>
    <xs:element ref="r2ml:ObjectVariable" minOccurs="0" maxOccurs="unbounded"/>
    <xs:element ref="r2ml:DataVariable" minOccurs="0" maxOccurs="unbounded"/>
   </xs:choice>
   <xs:element ref="r2ml:RuleSet" maxOccurs="unbounded"/>
  </xs:sequence>
  <xs:attribute ref="r2ml:externalVocabularyID"/>
  <xs:attribute ref="r2ml:externalVocabularyLanguage"/>
 </xs:complexType>
 <!-- 

Rule Set 

-->
 <xs:complexType name="RuleSet" abstract="true">
  <xs:sequence>
   <xs:element ref="r2mlv:Vocabulary" minOccurs="0"/>
   <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="r2ml:GenericVariable" minOccurs="0" maxOccurs="unbounded"/>
    <xs:element ref="r2ml:ObjectVariable" minOccurs="0" maxOccurs="unbounded"/>
    <xs:element ref="r2ml:DataVariable" minOccurs="0" maxOccurs="unbounded"/>
   </xs:choice>
  </xs:sequence>
  <xs:attribute ref="r2ml:ruleSetID" use="optional"/>
  <xs:attribute ref="r2ml:externalVocabularyID" use="optional"/>
  <xs:attribute ref="r2ml:externalVocabularyLanguage" use="optional"/>
 </xs:complexType>
 <!--

   IntegrityRuleSet. This element is designed  to capture a set of integrity rules (integrity constraints). Each rule set  it is identified by its unique ID

-->
 <xs:complexType name="IntegrityRuleSet" abstract="false">
  <xs:complexContent>
   <xs:extension base="r2ml:RuleSet">
    <xs:sequence>
     <xs:element ref="r2ml:IntegrityRule" maxOccurs="unbounded"/>
    </xs:sequence>
   </xs:extension>
  </xs:complexContent>
 </xs:complexType>
 <!--

 DerivationRuleSet. This element is designed  to capture a set of derivation rules. Each rule set  it is identified by its unique ID

-->
 <xs:complexType name="DerivationRuleSet" abstract="false">
  <xs:complexContent>
   <xs:extension base="r2ml:RuleSet">
    <xs:sequence>
     <xs:element ref="r2ml:DerivationRule" maxOccurs="unbounded"/>
    </xs:sequence>
   </xs:extension>
  </xs:complexContent>
 </xs:complexType>
 <!--

 ProductionRuleSet. This element is designed  to capture a set of production rules. Each rule set it is identified by its unique ID
 
-->
 <xs:complexType name="ProductionRuleSet" abstract="false">
  <xs:complexContent>
   <xs:extension base="r2ml:RuleSet">
    <xs:sequence>
     <xs:element ref="r2ml:ProductionRule" maxOccurs="unbounded"/>
    </xs:sequence>
   </xs:extension>
  </xs:complexContent>
 </xs:complexType>
 <!--

 ReactionRuleSet. This element is designed  to capture a set of reaction rules. Each rule set it is identified by its unique ID

 -->
 <xs:complexType name="ReactionRuleSet" abstract="false">
  <xs:complexContent>
   <xs:extension base="r2ml:RuleSet">
    <xs:sequence>
     <xs:element ref="r2ml:ReactionRule" maxOccurs="unbounded"/>
    </xs:sequence>
   </xs:extension>
  </xs:complexContent>
 </xs:complexType>
 <!-- 

The abstract concept of rule 

-->
 <xs:complexType name="Rule" abstract="true">
  <xs:sequence>
   <xs:element ref="r2ml:Documentation" minOccurs="0"/>
  </xs:sequence>
  <xs:attribute ref="r2ml:ruleID" use="optional"/>
 </xs:complexType>
 <!--

R2ML  Rules  definitions

 
Integrity Rules 
-->
 <!-- Abstract Integrity Rule -->
 <xs:complexType name="IntegrityRule" abstract="true">
  <xs:complexContent>
   <xs:extension base="r2ml:Rule">
    <xs:sequence>
     <xs:element ref="r2ml:constraint"/>
    </xs:sequence>
   </xs:extension>
  </xs:complexContent>
 </xs:complexType>
 <!-- Alethic Integrity Rule -->
 <xs:complexType name="AlethicIntegrityRule" abstract="false">
  <xs:complexContent>
   <xs:extension base="r2ml:IntegrityRule"/>
  </xs:complexContent>
 </xs:complexType>
 <!-- Deontic Integrity Rule -->
 <xs:complexType name="DeonticIntegrityRule" abstract="false">
  <xs:complexContent>
   <xs:extension base="r2ml:IntegrityRule"/>
  </xs:complexContent>
 </xs:complexType>
 <!-- 

Derivation Rule 

-->
 <xs:complexType name="DerivationRule" abstract="false">
  <xs:complexContent>
   <xs:extension base="r2ml:Rule">
    <xs:sequence>
     <xs:element ref="r2ml:conditions"/>
     <xs:element ref="r2ml:conclusion"/>
    </xs:sequence>
   </xs:extension>
  </xs:complexContent>
 </xs:complexType>
 <!-- 

Production Rule

-->
 <xs:complexType name="ProductionRule" abstract="false">
  <xs:complexContent>
   <xs:extension base="r2ml:Rule">
    <xs:sequence>
     <xs:element ref="r2ml:conditions"/>
     <xs:element ref="r2ml:producedAction"/>
     <xs:element ref="r2ml:postcondition" minOccurs="0"/>
    </xs:sequence>
   </xs:extension>
  </xs:complexContent>
 </xs:complexType>
 <!-- 

Reaction Rule

-->
 <xs:complexType name="ReactionRule" abstract="false">
  <xs:complexContent>
   <xs:extension base="r2ml:Rule">
    <xs:sequence>
     <xs:element ref="r2ml:triggeringEvent"/>
     <xs:element ref="r2ml:conditions" minOccurs="0"/>
     <xs:element ref="r2ml:producedAction"/>
     <xs:element ref="r2ml:postcondition" minOccurs="0"/>
    </xs:sequence>
   </xs:extension>
  </xs:complexContent>
 </xs:complexType>
 <xs:simpleType name="ExternalVocabularyLanguage">
  <xs:restriction base="xs:string">
   <xs:enumeration value="RDFS"/>
   <xs:enumeration value="OWL"/>
   <xs:enumeration value="UML"/>
  </xs:restriction>
 </xs:simpleType>
</xs:schema>
